shift-and algorithm